<title>修改會員資料</title>
<?php
// 含入系統（資料庫）設定檔
require('config.inc.php');
require('db.php');

session_start(); 
if($_SESSION['ID']!= null){
$ID=$_SESSION['ID'];
$UserNo=$_SESSION['UserNo']; 

// 連結資料庫伺服器
db_connect();

// 選擇資料庫
db_select();

//$user = $_POST['user'];
$pass = $_POST['txtPassword'];
$name = $_POST['txtName'];
$email = $_POST['txtEmail'];
$sex = $_POST['sex'];

// 建構 SQL 指令
$sql = '';
$sql .= 'update Authentication set Password = \'' . $pass . '\',';
$sql .= 'Name = \'' . $name . '\',';
$sql .= 'Email = \'' . $email . '\',';
$sql .= 'Sex = \'' . $sex . '\'';
$sql .= 'where Authentication . UserNo = ' . $UserNo . ';';

// 執行 SQL 指令
$result = mysql_query($sql) or die('Invalid query: ' . mysql_error());

$sql = '';
$sql .= 'SELECT * FROM Authentication WHERE UserNo=\'' . $UserNo . '\'';
$result = mysql_query($sql);

while ($row = mysql_fetch_assoc($result)) {
    $Password = $row['Password'];
    $Name = $row['Name'];
    $Sex = $row['Sex'];
    $Email = $row['Email'];
}

echo "$ID 帳號資料修改成功<br>";
echo "帳號資料如下：<br>";
echo "姓名：$Name<br>";
echo "密碼：$Password<br>";
echo "E-mail：$Email<br>";
echo "性別：$Sex<br>";

// 資料庫連結斷線
db_close();

}else{
   header("Location:"."login.html");
}

?>